﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Add_Album : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            //检测用户是否登录
            if (Session["USER_ID"] == null)
            {
                Response.Write("<script>('请先登录！');location.href='Index.aspx';</script>");
            }
        }
                
    }
    protected void AddAlbum_Button_Click(object sender, EventArgs e)
    {
        int User_Id =Int32.Parse(Session["USER_ID"].ToString());
        Album_Photo albumphoto = new Album_Photo();
        DateTime albumtime = DateTime.Now;
        string albumlogourl = "AlbumPhoto/" + FileUpload1.FileName;
        string exname = FileUpload1.FileName.Split('.')[1];
        if (exname.ToLower() == "gif" || exname.ToLower() == "jpg" || exname.ToLower() == "png")
        {
            FileUpload1.SaveAs(Server.MapPath(albumlogourl));
        }
        albumphoto.AddAlbum(AlbumName_Text.Text.ToString(), AlbumComment_Text.Text.ToString(), albumtime, User_Id, albumlogourl);
        Response.Write("<script>('添加相册成功！');location.href='ShowAlbum.aspx';</script>");
        
    }
}